//
//  AppStoreType.swift
//  imprint
//
//  Created by 小柠檬🍋 on 2025/1/6.
//

import Foundation
import SwiftUI
enum AppStorageType : String {
    //ai相关
    case TOGGLE_AI = "TOGGLE_AI" //ai总开关
    case TOGGLE_AI_EMOJI = "TOGGLE_AI_EMOJI" //表情
    case TOGGLE_AI_COMMENT = "TOGGLE_AI_COMMENT" //ai评论
    case TOGGLE_AI_DIARY = "TOGGLE_AI_DIARY" //ai日记
    case TOGGLE_AI_IMAGE = "TOGGLE_AI_IMAGE" //图片理解
    case TOGGLE_AI_IMAGE_COUNT = "TOGGLE_AI_IMAGE_COUNT" //图片理解数量
    case TOGGLE_AI_PERIOD = "TOGGLE_AI_PERIOD" //经期
    case TOGGLE_AI_VOICE = "TOGGLE_AI_VOICE" //语音来电
    case TOGGLE_AI_VIBRATE = "TOGGLE_AI_VIBRATE" // 语音震动
    case TOGGLE_AI_CHAT_DESC = "TOGGLE_AI_CHAT_DESC" //动作描述
    case TOGGLE_AI_SHORT = "TOGGLE_AI_SHORT" //简短聊天模式
    case TOGGLE_AI_EMOJI_PICTURE = "TOGGLE_AI_EMOJI_PICTURE" //是否开启表情包
    case AI_EMOJI_PICTURE = "AI_EMOJI_PICTURE" //表情包数据
    case AI_CHAT_TYPE = "AI_CHAT_TYPE" //ai 聊天模型
    case AI_COUNT_DEDUCT = "AI_COUNT_DEDUCT" //ai扣除次数,Double类型
    case AI_COUNT_LOCAL = "AI_COUNT_LOCAL" //ai本地次数,Double类型
    case TOGGLE_AI_RANDOM_MULTIPLE = "TOGGLE_AI_RANDOM_MULTIPLE" //随机多人回复
    case AI_CUSTOM = "AI_CUSTOM" //自定义ai json格式，废弃
    case AI_CUSTOM2 = "AI_CUSTOM2" //自定义ai json格式,最新
    case AI_HIDE_RECORD = "AI_HIDE_RECORD" //隐藏系统角色聊天记录  json格式
    case TOGGLE_MEMORY = "TOGGLE_MEMORY" //ai提取开关
    case TOGGLE_MEMORY_INJECT = "TOGGLE_MEMORY_INJECT" //ai注入开关
    case TOGGLE_CHAT_FUNC = "TOGGLE_CHAT_FUNC" //聊天互动模式
    case AI_FOLD_MODE = "AI_FOLD_MODE" //折叠模式， 0为当天显示，1为当月显示，2为当年显示，3全部显示，4全部关闭
    case AI_FOLD_STYLE = "AI_FOLD_STYLE" //折叠样式， 0为显示头像，1为名字，2为不显示

    
    //app设置
    case TOGGLE_PASSWORD = "TOGGLE_PASSWORD"
    case TOGGLE_FACE = "TOGGLE_FACE"
    case DATE_MODE = "DATE_MODE" //日期模式
    case GUIDE = "guide" //引导页面
    case THEME_COLOR = "THEME_COLOR" //主题颜色
    case PUSH_ACCOUNT = "PUSH_ACCOUNT" //本地推送账号
    case BUBBLE_BACKUP = "BUBBLE_BACKUP" //气泡-备份
    case BUBBLE_TIME = "BUBBLE_TIME" //气泡-时间
    case UPDATE_VERSION = "UPDATE_VERSION" //版本更新
    case NOTICE = "NOTICE" //公告
    case TASK_CALL_FIRST = "TASK_CALL_FIRST" //首次来电任务


    var id: String {
          self.rawValue
      }
}


class AppStorageManager : BaseViewModel {
    static let shared = AppStorageManager()
    //ai
    @AppStorage(AppStorageType.TOGGLE_AI.rawValue) var toggleAi = true//ai总开关
    @AppStorage(AppStorageType.TOGGLE_AI_EMOJI.rawValue) var toggleAiEmoji = false//表情
    @AppStorage(AppStorageType.TOGGLE_AI_COMMENT.rawValue) var toggleAiComment = true//ai评论
    @AppStorage(AppStorageType.TOGGLE_AI_DIARY.rawValue) var toggleAiDiary = true //ai日记
    @AppStorage(AppStorageType.TOGGLE_AI_IMAGE.rawValue) var toggleAiImage = false//图片理解
    @AppStorage(AppStorageType.TOGGLE_AI_IMAGE_COUNT.rawValue) var aiImageCount = 1//图片理解数量
    @AppStorage(AppStorageType.TOGGLE_AI_PERIOD.rawValue) var toggleAiPeriod = true//经期
    @AppStorage(AppStorageType.TOGGLE_AI_VOICE.rawValue) var toggleAivoice = true//语音来电
    @AppStorage(AppStorageType.TOGGLE_AI_VIBRATE.rawValue) var toggleAiVibrate = true// 语音震动
    @AppStorage(AppStorageType.TOGGLE_AI_CHAT_DESC.rawValue) var toggleAiDesc = false//动作描述
    @AppStorage(AppStorageType.TOGGLE_AI_SHORT.rawValue) var toggleAiShort = true//简短聊天模式
    @AppStorage(AppStorageType.TOGGLE_AI_EMOJI_PICTURE.rawValue) var toggleEmojiPicture = true//ai表情包
    @AppStorage(AppStorageType.AI_EMOJI_PICTURE.rawValue) var aiEmojiPicture:String = "{}"////表情包数据
    @AppStorage(AppStorageType.AI_CHAT_TYPE.rawValue) var aiModel = IChatModelType.TYPE_0//ai 聊天模型
    @AppStorage(AppStorageType.AI_COUNT_DEDUCT.rawValue) var deductAiCount = 0.0 //需要扣除的次数，-的为扣除，+ 为增加
    @AppStorage(AppStorageType.AI_COUNT_LOCAL.rawValue) var localAiCount = 8.0 ////ai本地次数,Double类型
    @AppStorage(AppStorageType.TOGGLE_AI_RANDOM_MULTIPLE.rawValue) var isRandomMultipleToggle = true //随机多人回复
    @AppStorage(AppStorageType.AI_CUSTOM.rawValue) var aiCustom : String = "{}"//自定义ai json格式,[type:json]
    @AppStorage(AppStorageType.AI_CUSTOM2.rawValue) var aiCustom2 : String = "{}"//自定义ai json格式,[type:objectId]
    @AppStorage(AppStorageType.AI_HIDE_RECORD.rawValue) var hideChatRecord : String = "[]" //隐藏系统角色聊天记录  json格式
    @AppStorage(AppStorageType.TOGGLE_MEMORY.rawValue) var toggleMemory = false//ai提取开关
    @AppStorage(AppStorageType.TOGGLE_MEMORY_INJECT.rawValue) var toggleMemoryInject = false //ai注入开关
    @AppStorage(AppStorageType.TOGGLE_CHAT_FUNC.rawValue) var toggleChatFunc = true //聊天互动模式
    @AppStorage(AppStorageType.AI_FOLD_MODE.rawValue) var foldMode = IFoldMode.TYPE_ALL//折叠模式
    @AppStorage(AppStorageType.AI_FOLD_STYLE.rawValue) var foldStyle = IFoldStyle.TYPE_AVATAR//折叠样式

    //app设置
    @AppStorage(AppStorageType.TOGGLE_PASSWORD.rawValue) var togglePassword = false
    @AppStorage(AppStorageType.TOGGLE_FACE.rawValue) var toggleFace = false
    @AppStorage(AppStorageType.DATE_MODE.rawValue) var dateMode = IDateModeType.DAY //日期模式
    @AppStorage(AppStorageType.GUIDE.rawValue) var isGuide = false //引导页面
    @AppStorage(AppStorageType.THEME_COLOR.rawValue)  var defaultColor = "ED5C41"//主题颜色
    @AppStorage(AppStorageType.PUSH_ACCOUNT.rawValue) var pushAccount:String = ""//本地推送账号
    @AppStorage(AppStorageType.BUBBLE_BACKUP.rawValue) var isBubbleBackups = true//气泡-备份
    @AppStorage(AppStorageType.BUBBLE_TIME.rawValue) var isBubbleTime = true//气泡-时间
    @AppStorage(AppStorageType.UPDATE_VERSION.rawValue) var updateVersionStorage = ""//版本更新
    @AppStorage(AppStorageType.NOTICE.rawValue) var noticeCache = ""//公告
    @AppStorage(AppStorageType.TASK_CALL_FIRST.rawValue) var taskFirst = true//首次来电任务

    func checkChatFuncToggle()-> Bool {
        if (toggleChatFunc) {
            return true
        }
        showTipsDialog(text: "需要开启互动模式才能使用该功能")
        return false
    }

}
